/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lab6.Home;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author THIEN
 */
public class Demo {

    public Demo() {
    }
    public static void main(String arg[])
    {
        try {
            Menu();
        } catch (IOException ex) {
            Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    static ManageList list = new ManageList();
    static InputStreamReader ISR = new InputStreamReader(System.in);
    static BufferedReader BR = new BufferedReader(ISR);
    
    public static void Menu() throws IOException {
        //init choice
        int choice;
        do {
            System.out.println("Welcome to Aprotrain-Aptech Lab on the-fly");
            System.out.println("1- Manage computer");
            System.out.println("2- Manage teacher");
            System.out.println("3- Manage student");
            System.out.println("4- Exit");
            System.out.println("*****Enter your choice: ");
            String temp = BR.readLine();
            choice = Integer.parseInt(temp);

            switch (choice) {
                case 1:
                        subMenu("Computer");
                        break;
                case 2:
                        subMenu("Teacher");
                        break;
                case 3:
                        subMenu("Student");
                        break;
                case 4:
                        System.exit(0);
                default:
                        System.out.println("Invalid choice ! Choose again");


            }
        } while (choice != 4);

    }
    public static void subMenu(String Object) throws IOException{
        int choice;
        System.out.println("1- Add "+Object+".");
        System.out.println("2- List "+Object+".");
        System.out.println("3- Search "+Object+".");
        System.out.println("4- Back to main menu.");
        System.out.println("*****Enter your choice: ");
        String temp = BR.readLine();
        choice = Integer.parseInt(temp);

        switch(choice){
            case 1:
                    list.addComputer(Object);
 
                    break;
            case 2:
                    list.Display(Object);
                    break;
            case 3:
                    list.Search(Object);
                    break;
            case 4:
                    Menu();
                    break;
        }

    }

}
